﻿using ET.Monitor.DAL;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ET.Monitor.Model
{
    public class StationModel
    {
        string userid, parentId, pointdesc, language;
        int sd = 10, pageCount = 10, pageIndex = 1;
        DateTime st = new DateTime(), et = new DateTime();
        string[] points = null;
        public StationModel()
        {
        }

        public StationModel(string uid)
        {
            userid = uid;
        }
        public StationModel(string uid, string[] point)
        {
            userid = uid;
            points = point;
        }
        public StationModel(string uid, DateTime sTime)
        {
            userid = uid;
            st = sTime;
        }
        public StationModel(string pid, string desc)
        {
            parentId = pid;
            pointdesc = desc;
        }
        public StationModel(string id, DateTime sTime, DateTime eTime)
        {
            userid = id;
            st = sTime;
            et = eTime;
        }
        string type = "";
        public StationModel(string id, string type, DateTime sTime, DateTime eTime)
        {
            userid = id;
            st = sTime;
            et = eTime;
            this.type = type;
        }
        int n = 0, i = 1;
        public StationModel(string id, DateTime sTime, DateTime eTime, int num, int index)
        {
            userid = id;
            st = sTime;
            et = eTime;
            n = num;
            i = index;
        }
        string t = "", f = "";
        public StationModel(string stationId, DateTime sTime, DateTime eTime, string title, string faultType, int count, int pageIndex)
        {
            userid = stationId;
            st = sTime;
            et = eTime;
            n = count;
            i = pageIndex;
            t = title;
            f = faultType;
        }
        public StationModel(string id, DateTime sTime, DateTime eTime, int second)
        {
            userid = id;
            st = sTime;
            et = eTime;
            sd = second;
        }

        public StationModel(string id, string name, DateTime sTime, DateTime eTime, int second)
        {
            userid = id;
            this.name = name;
            st = sTime;
            et = eTime;
            sd = second;
        }
        public StationModel(int pc, int pi, string sid, DateTime sTime, DateTime eTime)
        {
            pageCount = pc;
            pageIndex = pi;
            userid = sid;
            st = sTime;
            et = eTime;
        }

        public StationModel(string stationId, int count, int pageIndex)
        {
            userid = stationId;
            n = count;
            i = pageIndex;
        }

        public StationModel(string stationId, int count, int pageIndex, string type)
        {
            userid = stationId;
            n = count;
            i = pageIndex;
            this.type = type;
        }

        StationDAL dal = new StationDAL();

        #region 获取实时点数据 集合
        List<double[]> realVal;
        public List<double[]> RealVal
        {
            get
            {
                return dal.GetRealVal(userid, points);
            }

            set
            {
                realVal = value;
            }
        }
        #endregion

        //实时负荷
        object power;
        public object Power
        {
            get { return dal.GetStationPower(userid); }
            //set { power = value; }
        }
        public double[] ArrayPower
        {
            get { return dal.GetStationPowerArray(userid); }
            //set { power = value; }
        }


        //电站信息
        DataTable stations;

        public DataTable Stations
        {
            get { return dal.GetStations(userid); }
            set { stations = value; }
        }

        IList<Hashtable> listPoints;

        public IList<Hashtable> ListPoints
        {
            get { return dal.GetStationPoints(parentId, pointdesc); }
            set { ListPoints = value; }
        }

        #region 名字
        string name;

        public string Name
        {
            get { return dal.GetStationName(userid); }
            //set { rL = value; }
        }
        #endregion

        #region 获取电站
        DataTable dtStationInfo;

        public DataTable DtStationInfo
        {
            get { return dal.GetStationInfo(userid); }
            set { dtStationInfo = value; }
        }
        #endregion

        #region 天气状态
        int state;

        public int State
        {
            get { return dal.GetStationState(userid); }
            set { state = value; }
        }
        #endregion

        #region 实时发电量
        double realDL;

        public double RealDL
        {
            get { return dal.GetStationRealDl(userid); }
            //set { realDL = value; }
        }
        #endregion


        #region 实时发电量

        public double[] HisDL
        {
            get { return dal.GetStationHisDl(userid, st, et); }
            //set { realDL = value; }
        }

        public List<double[]> ArrayHisDL
        {
            get { return dal.GetArrayHisDl(userid, st); }
            //set { realDL = value; }
        }
        #endregion

        #region 一段时间发电量
        double dL;

        public double DL
        {
            get { return dal.GetStationDL(userid, st.ToString(), et.ToString()); }
            set { dL = value; }
        }

        DataTable _ArrayDL;
        public DataTable ArrayDL
        {
            get { return dal.GetArrayStationDL(userid, st.ToString(), et.ToString()); }
            set { _ArrayDL = value; }
        }

        double[] _GroupDL;
        public double[] GroupDL
        {
            get { return dal.GetGroupDL(userid, st.ToString(), et.ToString()); }
            set { _GroupDL = value; }
        }

        #endregion

        #region 获取电站
        DataTable dtPointOrgInfo;

        public DataTable DtPointOrgInfo
        {
            get { return dal.GetPointOrgInfo(userid); }
            set { dtPointOrgInfo = value; }
        }

        #endregion


        #region 容量
        double rL;

        public double RL
        {
            get { return dal.GetStationRL(userid); }
            //set { rL = value; }
        }


        public DataTable AllRL
        {
            get { return dal.GetAllStationRL(userid); }
            //set { inverterInfo = value; }
        }
        #endregion

        #region 温度
        object temperature;

        public object Temperature
        {
            get { return dal.GetStationTemperature(userid); }
            //set { temperature = value; }
        }
        #endregion

        #region 湿度
        object humidity;

        public object Humidity
        {
            get { return dal.GetStationHumidity(userid); }
            //set { humidity = value; }
        }
        #endregion

        #region 辐照度
        object irradiance;

        public object Irradiance
        {
            get { return dal.GetStationIrradiance(userid); }
            //set { irradiance = value; }
        }
        #endregion

        #region 逆变器数量
        double inverterCount;

        public double InverterCount
        {
            get { return dal.GetStationInverterCount(userid); }
            //set { inverterCount = value; }
        }
        #endregion

        #region 区域信息
        DataTable inverterInfo;

        public DataTable InverterInfo
        {
            get { return dal.GetStationInverterInfo(userid); }
            //set { inverterInfo = value; }
        }
        DataTable distraction;

        public DataTable Distraction
        {
            get { return dal.GetDistrictInfos(userid); }
            set { distraction = value; }
        }
        #endregion

        #region 节约标煤量
        double dlJM;

        public double DlJM
        {
            get
            {
                return dal.GetJM(userid);
            }

            set
            {
                dlJM = value;
            }
        }
        #endregion

        #region 二氧化碳减排量
        double dlEYHTPL;


        public double DlEYHTPL
        {
            get
            {
                return dal.GetEYHTJP(userid);
            }

            set
            {
                dlEYHTPL = value;
            }
        }
        #endregion

        #region 电站下逆变器
        DataTable dtInverters;

        public DataTable DtInverters
        {
            get { return dal.GetInverters(userid); }
            set { dtInverters = value; }
        }
        #endregion

        #region 电站基本测点
        DataTable dtStationPoint;

        public DataTable DtStationPoint
        {
            get { return dal.GetStationPoint(userid); }
            set { dtStationPoint = value; }
        }
        #endregion

        #region 电站状态
        int dtPowerPlantState;

        public int DtPowerPlantState
        {
            get { return dal.GetPowerPlantState(userid); }
            set { dtPowerPlantState = value; }
        }
        #endregion

        #region 累计发电量
        double sumDL;

        public double SumDL
        {
            get
            {
                return dal.SumDL(userid);
            }

            set
            {
                sumDL = value;
            }
        }
        #endregion

        #region 发电效率
        object efficiency;

        public object Efficiency
        {
            get { return dal.GetStationEfficiency(userid); }
            set { efficiency = value; }
        }
        #endregion

        #region 电站趋势 负荷
        //交流功率
        double[] line;

        public double[] Line
        {
            get { return dal.GetPowerPlantLine(userid, st, et, sd); }
            set { line = value; }
        }

        //直流功率
        double[] dcLine;

        public double[] DcLine
        {
            get { return dal.GetDCPowerLine(userid, st, et, sd); }
            set { dcLine = value; }
        }

        //并网功率
        double[] gridLine;

        public double[] GridLine
        {
            get { return dal.GetGridPowerLine(userid, st, et, sd); }
            set { gridLine = value; }
        }
        #endregion

        #region 电站趋势 离散率
        double[] dispersionRatio;

        public double[] DispersionRatio
        {
            get { return dal.GetDispersionRatioLine(userid, st, et, sd); }
            set { dispersionRatio = value; }
        }
        #endregion

        #region 电站趋势 电量
        double[] dlChart;

        public double[] DlChart
        {
            get { return dal.GetStationChartDl(userid, st, et, sd); }
            set { dlChart = value; }
        }
        #endregion

        #region 累计辐照度
        double sumIrradiance;
        public double SumIrradiance
        {
            get { return dal.GetSumIrradiance(userid, st.ToString(), et.ToString()); }
            set { sumIrradiance = value; }
        }
        #endregion

        #region 平均辐照度
        double avgIrradiance;

        public double AvgIrradiance
        {
            get { return dal.GetAvgIrradiance(userid, st.ToString(), et.ToString()); }
            set { avgIrradiance = value; }
        }
        //public double SumIrradiance
        //{
        //    get { return dal.GetSumIrradiance(userid, st.ToString(), et.ToString()); }
        //    set { sumIrradiance = value; }
        //}
        #endregion

        #region  平均功率
        double avgPower;

        public double AvgPower
        {
            get { return dal.GetAvgPower(userid, st.ToString(), et.ToString()); }
            set { avgPower = value; }
        }

        #endregion

        #region 累计发电效率
        double sumEfficiency;

        public double SumEfficiency
        {
            get { return dal.GetSumEfficiency(userid, st.ToString(), et.ToString()); }
            set { sumEfficiency = value; }
        }
        #endregion

        #region 日发电效率
        object dayEfficiency;

        public object DayEfficiency
        {
            get { return dal.GetDayEfficiency(userid, et.ToString()); }
            set { dayEfficiency = value; }
        }

        #endregion

        #region 月发电效率
        object monthEfficiency;

        public object MonthEfficiency
        {
            get { return dal.GetMonthEfficiency(userid, et.ToString()); }
            set { monthEfficiency = value; }
        }

        #endregion

        #region 年发电效率
        double yearEfficiency;

        public double YearEfficiency
        {
            get { return dal.GetYearEfficiency(userid, et.ToString()); }
            set { yearEfficiency = value; }
        }

        #endregion

        #region 单位容量发电量
        double unitDL;

        public double UnitDL
        {
            get { return dal.GetUnitDL(userid, st.ToString(), et.ToString()); }
            set { unitDL = value; }
        }
        #endregion

        #region 组件面积
        double assemblyArea;

        public double AssemblyArea
        {
            get { return dal.GetAssemblyArea(userid, et.ToString()); }
            set { assemblyArea = value; }
        }
        #endregion

        #region 系统效率
        double systemEfficiency;

        public double SystemEfficiency
        {
            get { return dal.GetSystemEfficiency(userid, st.ToString(), et.ToString()); }
            set { systemEfficiency = value; }
        }
        #endregion

        #region 组件计算转换效率
        double conversionEfficiency;

        public double ConversionEfficiency
        {
            get { return dal.GetConversionEfficiency(userid, st.ToString(), et.ToString()); }
            set { conversionEfficiency = value; }
        }
        #endregion

        #region Task
        DataTable dtTask;
        public DataTable DtTask
        {
            get { return dal.GetTask(userid, st.ToString(), et.ToString()); }
            set { dtTask = value; }
        }
        DataTable dtTaskPage;
        public DataTable DtTaskPage
        {
            get { return dal.GetTaskPage(userid, st.ToString(), et.ToString(), n, i); }
            set { dtTaskPage = value; }
        }
        #endregion

        #region Check
        bool check;

        public bool Check
        {
            get { return dal.Check(userid); }
            set { check = value; }
        }
        #endregion

        #region Persons
        DataTable dtPerson;

        public DataTable DtPerson
        {
            get { return dal.GetPerson(userid); }
            set { dtPerson = value; }
        }

        #endregion

        #region 设备预付费用
        DataTable dtPrepaid;

        public DataTable DtPrepaid
        {
            get { return dal.GetPrepaid(pageCount, pageIndex, userid, st, et); }
            set { dtPrepaid = value; }
        }

        int prepaidPageCount;

        public int PrepaidPageCount
        {
            get { return dal.GetPrepaidPageCount(userid, st, et); }
            set { prepaidPageCount = value; }
        }
        #endregion

        #region 初始化资产
        DataTable dtInitializationAssets;

        public DataTable DtInitializationAssets
        {
            get { return dal.GetInitializationAssets(pageCount, pageIndex, userid, st, et); }
            set { dtInitializationAssets = value; }
        }

        int initializationAssetsPageCount;

        public int InitializationAssetsPageCount
        {
            get { return dal.GetInitializationAssetsPageCount(userid, st, et); }
            set { initializationAssetsPageCount = value; }
        }

        #endregion

        #region 设备更换
        DataTable dtReplacementEquipment;

        public DataTable DtReplacementEquipment
        {
            get { return dal.GetReplacementEquipment(pageCount, pageIndex, userid, st, et); }
            set { dtReplacementEquipment = value; }
        }

        int replacementEquipmentPageCount;

        public int ReplacementEquipmentPageCount
        {
            get { return dal.GetReplacementEquipmentPageCount(userid, st, et); }
            set { replacementEquipmentPageCount = value; }
        }
        #endregion

        #region 设备预付款（采购）
        DataTable dtAdoptUpfrontPayment;

        public DataTable DtAdoptUpfrontPayment
        {
            get { return dal.GetAdoptUpfrontPayment(pageCount, pageIndex, userid, st, et); }
            set { dtAdoptUpfrontPayment = value; }
        }
        int adoptUpfrontPaymentPageCount;

        public int AdoptUpfrontPaymentPageCount
        {
            get { return dal.GetAdoptUpfrontPaymentPageCount(userid, st, et); }
            set { adoptUpfrontPaymentPageCount = value; }
        }
        #endregion

        #region 工资福利
        DataTable dtWagesBenefits;

        public DataTable DtWagesBenefits
        {
            get { return dal.GetWagesBenefits(pageCount, pageIndex, userid, st, et); }
            set { dtWagesBenefits = value; }
        }
        int wagesBenefitsPageCount;

        public int WagesBenefitsPageCount
        {
            get { return dal.GetWagesBenefitsPageCount(userid, st, et); }
            set { wagesBenefitsPageCount = value; }
        }
        double wagesBenefitsSum;

        public double WagesBenefitsSum
        {
            get { return dal.GetWagesBenefitsSum(userid, st, et); }
            set { wagesBenefitsSum = value; }
        }
        #endregion

        #region 运维费用
        DataTable dtGetOperation;

        public DataTable DtGetOperation
        {
            get { return dal.GetOperation(pageCount, pageIndex, userid, st, et); }
            set { dtGetOperation = value; }
        }
        int operationPageCount;

        public int OperationPageCount
        {
            get { return dal.GetOperationPageCount(userid, st, et); }
            set { operationPageCount = value; }
        }

        double operationSum;

        public double OperationSum
        {
            get { return dal.GetOperationSum(userid, st, et); }
            set { operationSum = value; }
        }

        DataTable MonthOperation;

        public DataTable MonthOperation1
        {
            get { return dal.GetMonthOperation(userid, st, et); }
            set { MonthOperation = value; }
        }
        #endregion

        #region 国家
        object country;

        public object Country
        {
            get { return dal.GetCountry(userid); }
            set { country = value; }
        }
        #endregion

        #region 质保期
        DataTable dtGuaranteePeriod;

        public DataTable DtGuaranteePeriod
        {
            get { return dal.GetGuaranteePeriod(userid); }
            set { dtGuaranteePeriod = value; }
        }
        #endregion

        #region AreaId
        DataTable dtAreaId;

        public DataTable DtAreaId
        {
            get { return dal.GetAreaId(userid); }
            set { dtAreaId = value; }
        }
        #endregion

        #region 大类故障详细信息 逆变器
        DataTable dtFaultRecord;

        public DataTable DtFaultRecord
        {
            get { return dal.GetFaultRecord(userid, type, st, et); }
            set { dtFaultRecord = value; }
        }
        #endregion

        #region 大类故障次数 逆变器
        DataTable dtDtFaultRecordCount;

        public DataTable DtDtFaultRecordCount
        {
            get { return dal.GetFaultRecordCount(userid, st, et); }
            set { dtDtFaultRecordCount = value; }
        }
        DataTable dtDFaultRecordCountAll;

        public DataTable DtDFaultRecordCountAll
        {
            get { return dal.GetFaultRecordCount(userid); }
            set { dtDFaultRecordCountAll = value; }
        }

        DataTable dtFaultDetailCount;

        public DataTable DtFaultDetailCount
        {
            get { return dal.GetFaultDetailCount(userid); }
            set { dtFaultDetailCount = value; }
        }
        #endregion

        #region 小类故障明细 逆变器
        DataTable dtFaultDetail;

        public DataTable DtFaultDetail
        {
            get { return dal.GetFaultDetail(userid, type, st, et); }
            set { dtFaultDetail = value; }
        }

        DataTable dtFaultDetailInfo;

        public DataTable DtFaultDetailInfo
        {
            get { return dal.GetFaultDetaiInfo(userid); }
            set { dtFaultDetailInfo = value; }
        }
        DataTable dtFaultDetailInfoList;

        public DataTable DtFaultDetailInfoList
        {
            get
            {
                return dal.GetFaultDetailInfo(userid, st, et, t, f, n, i);
            }

            set
            {
                dtFaultDetailInfoList = value;
            }
        }

        int faultDetailInfoListCount;

        public int FaultDetailInfoListCount
        {
            get
            {
                return dal.GetFaultDetailInfoCount(userid, st, et, t, f, n, i);
            }

            set
            {
                faultDetailInfoListCount = value;
            }
        }
        #endregion

        #region 电站上一级关系 市
        DataTable dtCity;

        public DataTable DtCity
        {
            get
            {
                return dal.GetCityID(userid);
            }

            set
            {
                dtCity = value;
            }
        }
        #endregion

        #region 同工况下时间范围内发电量
        private double cconditionDL;

        public double CconditionDL
        {
            get
            {
                return dal.GetCconditionDL(userid, st, et);
            }

            set
            {
                cconditionDL = value;
            }
        }
        #endregion

        #region 当前故障统计
        int realFaultCountType;
        public int RealFaultCountType
        {
            get { return dal.GetTotalFaultDetailInfoCount(userid, n, i, type); }
        }
        DataTable realFaultDtType;
        public DataTable RealFaultDtType
        {
            get { return dal.GetTotalFaultDetailInfo(userid, n, i, type); }
        }



        int realFaultCount;

        public int RealFaultCount
        {
            get
            {
                return dal.GetTotalFaultDetailInfoCount(userid, n, i);
            }

            set
            {
                realFaultCount = value;
            }
        }

        DataTable realFaultDt;

        public DataTable RealFaultDt
        {
            get
            {
                return dal.GetTotalFaultDetailInfo(userid, n, i);
            }

            set
            {
                realFaultDt = value;
            }
        }

        DataTable realFaultDtAll;
        public DataTable RealFaultDtAll
        {
            get { return dal.GetTotalFaultDetailInfoALL(userid); }
        }
        #endregion

        #region 电站电量统计

        #region 年
        DataTable dtTotalYearDL;

        public DataTable DtTotalYearDL
        {
            get
            {
                return dal.GetStationYearTotalDLByTime(userid, st, et);
            }

            set
            {
                dtTotalYearDL = value;
            }
        }
        #endregion

        #region 月
        DataTable dtTotalMonthDL;

        public DataTable DtTotalMonthDL
        {
            get
            {
                return dal.GetStationMonthTotalDLByTime(userid, st, et);
            }

            set
            {
                dtTotalMonthDL = value;
            }
        }
        #endregion

        #region 日
        DataTable dtTotalDayDL;

        public DataTable DtTotalDayDL
        {
            get
            {
                return dal.GetStationDayTotalDLByTime(userid, st, et);
            }

            set
            {
                dtTotalDayDL = value;
            }
        }
        #endregion

        #region 小时
        DataTable dtTotalHourDL;

        public DataTable DtTotalHourDL
        {
            get
            {
                return dal.GetStationHourTotalDLByTime(userid, st, et);
            }

            set
            {
                dtTotalHourDL = value;
            }
        }
        #endregion

        #endregion

        #region 累计时间范围内平均功率
        DataTable dtYearAvgPower;

        public DataTable DtYearAvgPower
        {
            get
            {
                return dal.GetStationYearAvgPowerByTime(userid, st, et);
            }

            set
            {
                dtYearAvgPower = value;
            }
        }
        DataTable dtMonthAvgPower;

        public DataTable DtMonthAvgPower
        {
            get
            {
                return dal.GetStationMonthAvgPowerByTime(userid, st, et);
            }

            set
            {
                dtMonthAvgPower = value;
            }
        }
        DataTable dtDayAvgPower;

        public DataTable DtDayAvgPower
        {
            get
            {
                return dal.GetStationDayAvgPowerByTime(userid, st, et);
            }

            set
            {
                dtDayAvgPower = value;
            }
        }
        DataTable dtHourAvgPower;

        public DataTable DtHourAvgPower
        {
            get
            {
                return dal.GetStationHourAvgPowerByTime(userid, st, et);
            }

            set
            {
                dtHourAvgPower = value;
            }
        }
        #endregion

        #region 累计发电量
        double dlSumDL;

        public double DlSumDL
        {
            get
            {
                return dal.GetSumDL(userid);
            }

            set
            {
                dlSumDL = value;
            }
        }

        #endregion

        #region 获取电站图片
        object objUrl;

        public object ObjUrl
        {
            get
            {
                return dal.GetStationImg(userid);
            }

            set
            {
                objUrl = value;
            }
        }

        public DataTable DtStationName
        {
            get
            {
                return dal.GetStationNameByName(parentId, pointdesc);
            }

            set
            {
                dtStationName = value;
            }
        }


        #endregion

        #region  获取电站名称
        DataTable dtStationName;
        #endregion

        #region 统计所有电站小类故障数量
        DataTable dtStationFaultDetaiCount;
        public DataTable DtStationFaultDetaiCount
        {
            get
            {
                return dal.GetFaultDetaiCount();
            }

            set
            {
                dtStationFaultDetaiCount = value;
            }
        }
        #endregion

        #region  增加查询当前所有故障方法
        DataTable dtFault;
        public DataTable DtFault
        {
            get
            {
                return dal.GetFault();
            }

            set
            {
                dtFault = value;
            }
        }


        #endregion




        string _sid = "", _pid = "", _dt = "", _type = "", _value = "";
        public StationModel(string sid, string pid, string dt, string type)
        {
            this._sid = sid;
            this._pid = pid;
            this._dt = dt;
            this._type = type;
        }
        public StationModel(string sid, string pid, string dt, string type, string value)
        {
            this._sid = sid;
            this._pid = pid;
            this._dt = dt;
            this._type = type;
            this._value = value;
        }

        #region 电量信息维护 - 单云龙
        DataTable dtDL;

        public DataTable DtDL
        {
            get { return dal.GetDLByPid(_sid, _pid, _dt, _type); }
            set { dtDL = value; }
        }

        bool setListStatics;

        public bool SetListStatics
        {
            get { return dal.SetListStatics(_sid, _pid, _dt, _type, _value); }
            set { setListStatics = value; }
        }

        #endregion

        #region 辐照度趋势
        double[] irradianceLine = null;
        public double[] IrradianceLine
        {
            get { return dal.GetIrradianceLine(userid, st, et, sd); }
            set { irradianceLine = value; }
        }
        #endregion

        #region N条趋势查询
        double[][] lines = null;

        public double[][] Lines
        {
            get
            {
                return dal.GetLine(userid, name, st, et, sd);
            }

            set
            {
                lines = value;
            }
        }
        #endregion

        #region 获取理论发电量
        double[] valElec;

        public double[] ValElec
        {
            get
            {
                return dal.GetTheoreticalQuantity(userid);
            }

            set
            {
                valElec = value;
            }
        }
        #endregion

        #region PR
        double[][] pr = null;

        public double[][] Pr
        {
            get
            {
                return dal.GetStationPR(userid, name, st, et, sd);
            }

            set
            {
                pr = value;
            }
        }
        #endregion
    }
}
